package com.wander.patterns.create.prototype;

import lombok.Data;

import java.util.Date;

/**
 * @description:羊
 * @author: zhuyong
 * @create: 2019-09-06 16:18
 **/
@Data
public class Sheep implements Cloneable{

    private String name;
    private int age;
    private int sex;
    private Date birthDay;

    @Override
    protected Object clone() throws CloneNotSupportedException {
        Sheep sheep = (Sheep) super.clone();
        //深拷贝的实现方式之一 : 将属性也拷贝一份
        sheep.birthDay = this.birthDay;
        return sheep;
    }

    @Override
    public String toString() {
        return "Sheep{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", sex=" + sex +
                '}';
    }
}
